﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lib
{
        [Serializable()]
    public class MeasuredValues
    {
        public int heartBeat { get; private set; }
        public int rpm { get; private set; }
        public int speed { get; private set; }
        public int distance { get; private set; }
        public int power { get; private set; }
        public int energy { get; private set; }
        public DateTime time { get; private set; }
        public int currentPower { get; private set; }

        public MeasuredValues(int heartBeat, int rpm, int speed, int distance, int power, int energy, DateTime time, int currentPower)
        {
            
            this.heartBeat = heartBeat;
            this.rpm = rpm;
            this.speed = speed;
            this.distance = distance;
            this.power = power;
            this.energy = energy;
            this.time = time;
            this.currentPower = currentPower;
        }

        public MeasuredValues(String s)
        {
            string[] measurements = s.Split(' ');
            System.Diagnostics.Debug.WriteLine("Lel: " + measurements[0]/*+"mijn::   "+s*/);
            heartBeat = Convert.ToInt32(measurements[0]);
            rpm = Convert.ToInt32(measurements[1]);
            speed = Convert.ToInt32(measurements[2]);
            distance = Convert.ToInt32(measurements[3]);
            power = Convert.ToInt32(measurements[4]);
            energy = Convert.ToInt32(measurements[5]);
            string[] datum = measurements[6].Split('-');
            time = new DateTime(Convert.ToInt32(datum[2]), Convert.ToInt32(datum[1]), Convert.ToInt32(datum[0]));
            currentPower = Convert.ToInt32(measurements[7]);            
        }

        public String getString()
        {
            string result = heartBeat + " " +  rpm + " " + speed + " " + distance + " " + power + " " + energy + " " + time.ToString().Replace(":","") + " " + currentPower;
            System.Diagnostics.Debug.WriteLine("Measure: " + result);
            return result;
        }


    }
}
